<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html>
<head>
<title></title>
<!-- 引入EasyUI的相关css和js文件 -->
<link href="EasyUI/themes/default/easyui.css" rel="stylesheet"
	type="text/css" />
<link href="EasyUI/themes/icon.css" rel="stylesheet" type="text/css" />
<link href="EasyUI/demo.css" rel="stylesheet" type="text/css" />
<script src="EasyUI/jquery.min.js" type="text/javascript"></script>
<script src="EasyUI/jquery.easyui.min.js" type="text/javascript"></script>
<script src="EasyUI/easyui-lang-zh_CN.js" type="text/javascript"></script>
</head>
<body>
	<table id="dg_patientinfolist" class="easyui-datagrid"></table>
	<!-- 创建datagrid控件的工具栏 -->
	<div id="tb_patientinfo1" style="padding: 2px 5px;">
		<a href="javascript:void(0)" class="easyui-linkbutton"
			iconCls="icon-add" plain="true" onclick="addPatient1();">添加</a> <a
			href="javascript:void(0)" class="easyui-linkbutton"
			iconCls="icon-edit" plain="true" onclick="updatePatient();">修改</a> <a
			href="javascript:void(0)" class="easyui-linkbutton"
			iconCls="icon-remove" onclick="deletePatient();" plain="true">删除</a>
	</div>
	<!-- 创建查询工具栏 -->
	<div id="searchtb_patientinfo1" style="padding: 2px 5px;">
		<form id="searchForm_patientinfo" method="post">
			<div style="padding: 3px">
				病人姓名&nbsp;&nbsp;<input class="easyui-textbox" name="name"
					id="search_name" style="width: 110px" />
			</div>
			<div style="padding: 3px">
				病人卡号&nbsp;&nbsp;<input class="easyui-textbox" name="diagnosticcard"
					id="search_diagnosticcard" style="width: 110px" /> &nbsp;&nbsp;<a
					href="javascript:void(0)" class="easyui-linkbutton"
					iconCls="icon-search" plain="true" onclick="searchPatient();">查找</a>
			</div>
		</form>
	</div>
	<!-- 创建修改部分信息提示框 -->
	<div id="dlg_patientinfo" class="easyui-dialog" title="修改部分信息" closed="true"
		style="width: 500px;">
		<div style="padding: 10px 60px 20px 60px">
			<form id="ff_patientinfo1" method="POST" action="">
				<table cellpadding="5">

					<tr>
						<td>诊疗卡号:</td>
						<td><input class="easyui-textbox" type="text" id="diagnosticcard"
							name="diagnosticcard" readonly="readonly" data-options="required:true"></input></td>
					</tr>
					<tr>
						<td>病人姓名:</td>
						<td><input class="easyui-textbox" type="text" id="name"
							name="name" readonly="readonly" data-options="required:true"></input></td>
					</tr>

					<tr>
						<td>年龄:</td>
						<td><input class="easyui-textbox" type="text"
							id="age" name="age"
							data-options="required:true"></input></td>
					</tr>
					<tr>
						<td>手机号码:</td>
						<td><input class="easyui-textbox" type="text"
							id="phone" name="phone"
							data-options="required:true"></input></td>
					</tr>
					<tr>
						<td>家庭地址:</td>
						<td><input class="easyui-textbox" type="text"
							id="address" name="address"
							data-options="required:true"></input></td>
					</tr>					
					<tr>
						<td>联系人:</td>
						<td><input class="easyui-textbox" type="text" id="contacts"
							name="contacts" data-options="required:true"></input></td>
					</tr>

					<tr>
						<td>联系人电话:</td>
						<td><input class="easyui-textbox" type="text" id="cphone"
							name="cphone" data-options="required:true"></input></td>
					</tr>
					<tr>
						<td>既往病史:</td>
						<td><input class="easyui-textbox" name="pastmedicalhistory"
							id="pastmedicalhistory" data-options="multiline:true"
							style="height: 60px" data-options="required:true"></input></td>
					</tr>

				</table>
			</form>
			<div style="text-align: center; padding: 5px">
				<a href="javascript:void(0)" class="easyui-linkbutton"
					onclick="savePatientinfo();">保存</a> <a href="javascript:void(0)"
					class="easyui-linkbutton" onclick="clearForm();">清空</a>
			</div>
		</div>
	</div>
	<script type="text/javascript">
	<!--
		//-->
		$(function() {
			$('#dg_patientinfolist').datagrid({
				singleSelect : true, //设置datagrid为单选
				url : 'patient/querybyform', //为datagrid设置数据源
				//pagination : true, //启用分页
				//pageSize : 10, //设置初始每页记录数（页大小）
				//pageList : [ 10, 15, 20 ], //设置可供选择的页大小
				queryParams : {
					doctorno : '${sessionScope.doctor.doctorno}',
				},
				rownumbers : true, //显示行号
				fit : true, //设置自适应
				toolbar : '#tb_patientinfo1', //为datagrid添加工具栏
				header : '#searchtb_patientinfo1', //为datagrid标头添加搜索栏
				columns : [ [ { //编辑datagrid的列
					title : '序号',
					field : 'no',
					align : 'center',
					checkbox : true
				}, {
					field : 'diagnosticcard',
					title : '诊疗卡号',
					width : 170
				}, {
					field : 'name',
					title : '姓名',
					align : 'center',
					width : 70
				}, {
					field : 'age',
					title : '年龄',

					width : 60
				}, /*{
									field : 'status',
									title : '药品状态',					
									width : 60
								},*/{
					field : 'phone',
					title : '手机号码',
					width : 100
				}, {
					field : 'country',
					title : '国家',

					width : 60
				},{
					field : 'nation',
					title : '民族',

					width : 60
				},{
					field : 'married',
					title : '婚姻情况',

					width : 70
				},{
					field : 'sex',
					title : '性别',

					width : 60
				},{
					field : 'address',
					title : '家庭住址:',
					width : 120
				},{
					field : 'contacts',
					title : '联系人',

					width : 60
				},{
					field : 'cphone',
					title : '联系人电话:',

					width : 100
				}, {
					field : 'born',
					title : '出生日期',
					width : 120
				},/* {
											field : 'num',
											title : '库存',
											width : 50
										}, */{
					field : 'pastmedicalhistory',
					title : '既往病史',
					width : 450
				} ] ]
			});
		});
		 function addPatient1(currentTab) {
	    	 
	    	  /*$('#tabs').tabs('add', {
					title : "增加病人信息",
					href : 'add_patient.jsp',
					closable : true
				});
			*/	
			var currentTab = $('#tabs').tabs('getSelected');

			    var url = 'add_patient.jsp'

			    $("#tabs").tabs('update',{
			        tab: currentTab,
			        options:{
			        	title : "增加病人信息",
			            href: url
			            
			        }
			    });
			currentTab.panel('refresh');

			
		}
		 //修改部分病人信息
		 function updatePatient() {
				var rows = $("#dg_patientinfolist").datagrid('getSelections');
				if (rows.length > 0) {					
					var row = $("#dg_patientinfolist").datagrid("getSelected");
					if (row) {
						$("#dlg_patientinfo").dialog("open").dialog('setTitle',
								'修改病人信息');

						$("#ff_patientinfo1").form("load", {
							"age" : row.age,
							"name" : row.name,
							"phone" : row.phone,
							"address" : row.address,
							"contacts" : row.contacts,
							"cphone" : row.cphone,
							"pastmedicalhistory" : row.pastmedicalhistory,
							"diagnosticcard" : row.diagnosticcard,

						});
						
						urls = "patient/updatepatient";
					}
				} else {
					$.messager.alert('提示', '请选择要修改的行', 'info');
				}
		}
		 function savePatientinfo() {
				$("#ff_patientinfo1").form("submit", {
					url : urls, //使用参数				
					success : function(result) {
						var result = eval('(' + result + ')');
						if (result.success == 'true') {	
							$("#dg_patientinfolist").datagrid("reload");
							$("#dlg_patientinfo").dialog("close");
						}
						$.messager.show({
							title : "提示信息",
							msg : result.message
						});
					}
				});
				$("#dg_patientinfolist").datagrid("reload");
			}
		 	//根据条件查询病人
			function searchPatient() {
				var search_name = $('#search_name').textbox("getValue");
				var search_diagnosticcard = $('#search_diagnosticcard').textbox("getValue");

				$("#dg_patientinfolist").datagrid('load', {
					"name" : search_name,
					"diagnosticcard" : search_diagnosticcard
				});
			}
	</script>
</body>
</html>